<template>
  <component
    :is="component"
    :item="item"
    :operate-param="operateParam"
    :table-data="tableData"
    :selected="selected"
    :columns="columns"
    :pagination="pagination"
    @showLoading="showLoading"
    @reqData="reqData"
  />
</template>

<script>
import heyTableElButtonDetail from '../components/hey-table-el-button-detail'
import heyTableElButtonAdd from '../components/hey-table-el-button-add'
import heyTableElButtonEdit from './hey-table-el-button-edit'
import heyTableElButtonDelete from '../components/hey-table-el-button-delete'
import heyTableElButtonConf from '../components/hey-table-el-button-conf'
import heyTableElButtonAntiConf from '../components/hey-table-el-button-anti-conf'
import heyTableElButtonConfirm from '../components/hey-table-el-button-confirm'
import heyTableElButtonLink from '../components/hey-table-el-button-link'
import heyTableElButtonTask from '../components/hey-table-el-button-task'
import heyTableElButtonOther from '../components/hey-table-el-button-other'
const BUTTON_TYPE = {
  detail: 'detail', // 详细信息
  add: 'add', // 新增
  edit: 'edit', // 修改
  delete: 'delete', // 删除
  conf: 'conf', // 审核
  antiConf: 'anti-conf', // 反审核
  confirm: 'confirm', // 弹出确认操作
  link: 'link', // 跳转页面
  task: 'task', // 跳转任务进度页面
  other: 'other' // 其他操作,弹出确认XXX操作
}
export default {
  name: 'HeyTableElButton',
  components: {
    heyTableElButtonDetail,
    heyTableElButtonAdd,
    heyTableElButtonEdit,
    heyTableElButtonDelete,
    heyTableElButtonConf,
    heyTableElButtonAntiConf,
    heyTableElButtonLink,
    heyTableElButtonTask,
    heyTableElButtonConfirm,
    heyTableElButtonOther
  },
  props: {
    item: {
      type: Object,
      required: true
    },
    pagination: {
      type: Object,
      default: () => {
        return {
          page_jump: 1, // 多页查询跳转页码
          rec_in_page: 10 // 多页查询每页笔数
        }
      }
    },
    /* item: {
        name: '修改',//按钮显示的名称
        disabled: false, // 是否置灰
        type: 'update',//类型 detail add update delete conf antiConf confirm other
        selectType: '0',// '0' 不控是否选中 '1' 单选 '2'多选
        operateParam: { // 同下operateParam，相当于下面是总的，所有列表内button继承总的配置，单独button写了覆盖
        },
      },*/
    operateParam: Object,
    /* operateParam: {
        transId: 'AL0440401', // 交易号,
        reqRow: false, // 为true时跳转页面将传递整条当前选中数据
        param: { // 请求参数
          AstPrtfl_Cd: '', // 写空字符串表示从选定数据里选取自动赋值，写死值则以写死值为准
          Ast_GRP: 'AstPrtfl_Cd,AstPrtfl_Nm' // 多个字段以逗号隔开，或者写{}表示传所选所有数据
        },
        isValid: true, // 默认开启校验
        autoSetParam: true, // 自动拼Rcrd_ID、pageType参数在路由后面
        validate: [{
          key: 'Last_Chk_StCd', // 对应column上的字段
          value: '2', // 列的值,正则写法，多个值1|3
          msg: '只有审核通过的数据才能进行该操作', // 出错提示信息
          flag: true // 为true表示只有字段Last_Chk_StCd值为2才允许后续操作，为false表示除了2都允许后续操作
        }], // 校验规则
        url: { // 跳转页面
          path: '', // 下面2个参数2选1传入，都填path优先级高于name
          name: 'AllocateAssetPortFolioBasicInfo'
        },
        fn: function (operateParam) { // 执行完成后回调,type为other直接走该回调方法，不进行任何校验
        },
        setParam: function (param) { // 执行操作之前动态赋值参数
            this.setParam(param)
        }
      },*/
    tableData: Array,
    selected: Array,
    columns: Array
  },
  data() {
    return {}
  },
  computed: {
    component() {
      return 'hey-table-el-button-' + (BUTTON_TYPE[this.item.type] || 'other')
    }
  },
  mounted() {

  },
  methods: {
    showLoading(flag) {
      this.$emit('showLoading', flag)
    },
    reqData() {
      this.$emit('reqData')
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
